package com.yao.longhan.ui.fragment;

import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;

import com.yao.longhan.R;
import com.yao.longhan.ui.base.BaseFragment;
import com.yao.longhan.presenter.adapter.BookcaseAdapter;

import butterknife.BindString;
import butterknife.BindView;

/**
 * Created by heyao on 2017/7/24.
 */

public class BookcaseFragment extends BaseFragment {

    @BindView(R.id.table_layout_bookcase)
    TabLayout mTabLayout;

    @BindView(R.id.view_pager_bookcase)
    ViewPager mViewPager;

    @BindString(R.string.bookcase_male)
    String male;
    @BindString(R.string.bookcase_female)
    String female;

    @Override
    protected int layoutId() {
        return R.layout.fragment_bookcase;
    }

    @Override
    protected void initAfter() {
        String[] title = new String[]{male, female};
        mTabLayout.setTabMode(TabLayout.MODE_FIXED);
        mTabLayout.addTab(mTabLayout.newTab().setText(title[0]), 0);
        mTabLayout.addTab(mTabLayout.newTab().setText(title[1]), 1);
        BookcaseAdapter bookcaseAdapter = new BookcaseAdapter(getChildFragmentManager(),title);
        mViewPager.setAdapter(bookcaseAdapter);
        mTabLayout.setupWithViewPager(mViewPager);
    }
}
